import {http} from '../utils'

exports.addUniversity = function (data) {
  return http({
    type:'post',
    url:'/University',
    data:data,
  })
}
exports.reviseUniversity = function (id,data) {
  return http({
    type:'put',
    url:`/University?id=${id}`,
    data:data
  })
}
exports.deleteUniversity = function (id) {
  return http({
    type:'delete',
    url:`/University?Id=${id}`
  })
}

exports.getUniversityList = function (channel,keyWord,tag) {
  let url = '/University/List?'
  if(channel) url = url + `&channel=${channel}`
  if(keyWord) url = url + `&keyWord=${keyWord}`
  if(tag) url = url + `&tag=${tag}`
  return http({
    type:'get',
    url: url,
  })
}

exports.getUniversityDetail = function (id) {
  return http({
    type:'get',
    url:`/University/Detail?id=${id}`
  })
}
exports.addCollege = function (data) {
  return http({
    type:'post',
    url:'/University/School',
    data:data,
  })
}
exports.reviseCollege = function (cid,data) {
  return http({
    type:'put',
    url:`/University/School?id=${cid}`,
    data:data,
  })
}

exports.deleteCollege= function (id) {
  return http({
    type:'delete',
    url:`/University/School?Id=${id}`
  })
}

exports.getCollegeList = function (uid) {
  return http({
    type:'get',
    url:`/University/School/List?universityId=${uid}`
  })
}

exports.getCollegeDetail = function (cid) {
  return http({
    type:'get',
    url:`/University/School/Detail?id=${cid}`
  })
}

exports.getMajorList = function (cid,type,keyword) {
  let url = '/University/Major/List?'
  if(cid) url = url + `&schoolId=${cid}`
  if(type) url = url + `&grade=${type}`
  if(keyword) url = url + `&keyWord=${keyword}`
  return http({
    type:'get',
    url: url
  })
}

exports.getMajorDetail = function (mid) {
  return http({
    type:'get',
    url:`/University/Major/Detail?id=${mid}`
  })
}

exports.addMajor=function (data) {
  return http({
    type:'post',
    url:'/University/Major',
    data:data,
  })
}
exports.reviseMajor = function (mid,data) {
  return http({
    type:'put',
    url:`/University/Major?id=${mid}`,
    data:data,
  })
}

exports.deleteMajor= function (id) {
  return http({
    type:'delete',
    url:`/University/Major?Id=${id}`
  })
}


